<?php

class CCoreSocketImapFetch
{
	#<editor-fold defaultstate="collapsed" desc="constants">
	const ALL = 'ALL';
	const FAST = 'FAST';
	const FULL = 'FULL';
	const BODY = 'BODY';
	const BODY_PEEK = 'BODY.PEEK';
	const BODYSTRUCTURE = 'BODYSTRUCTURE';
	const ENVELOPE = 'ENVELOPE';
	const FLAGS = 'FLAGS';
	const INTERNALDATE = 'INTERNALDATE';
	const RFC822 = 'RFC822';
	const RFC822_HEADER = 'RFC822.HEADER';
	const RFC822_SIZE = 'RFC822.SIZE';
	const RFC822_TEXT = 'RFC822.TEXT';
	const UID = 'UID';
	const INDEX = 'INDEX';
	#</editor-fold>

	/**
	 * @param	array	$aFetchItems
	 * @return	array
	 */
	public static function ChangeFetchItemsBefourRequest($aFetchItems)
	{
		CCore::CheckTypes(array('$aFetchItems'));
				
		$aReturn = array(self::UID);
		foreach ($aFetchItems as $sFetchItem)
		{
			switch ($sFetchItem)
			{
				default:
					$aReturn[] = $sFetchItem;
					break;
				case self::INDEX:
					break;
				case self::ALL:
					$aReturn[] = self::FLAGS;
					$aReturn[] = self::INTERNALDATE;
					$aReturn[] = self::RFC822_SIZE;
					$aReturn[] = self::ENVELOPE;
					break;
				case self::FAST:
					$aReturn[] = self::FLAGS;
					$aReturn[] = self::INTERNALDATE;
					$aReturn[] = self::RFC822_SIZE;
					break;
				case self::FULL:
					$aReturn[] = self::FLAGS;
					$aReturn[] = self::INTERNALDATE;
					$aReturn[] = self::RFC822_SIZE;
					$aReturn[] = self::ENVELOPE;
					$aReturn[] = self::BODY;
					break;

			}
		}
		return array_unique($aReturn);
	}
}

class CCoreSocketImapStatus
{
	#<editor-fold defaultstate="collapsed" desc="constants">
	const MESSAGES = 'MESSAGES';
	const RECENT = 'RECENT';
	const UNSEEN = 'UNSEEN';
	const UIDNEXT = 'UIDNEXT';
	const UIDVALIDITY = 'UIDVALIDITY';
	#</editor-fold>
}

class CCoreSocketImapStoreAction
{
	#<editor-fold defaultstate="collapsed" desc="constants">
	const SET_FLAGS = 'FLAGS';
	const SET_FLAGS_SILENT = 'FLAGS.SILENT';
	const ADD_FLAGS = '+FLAGS';
	const ADD_FLAGS_SILENT = '+FLAGS.SILENT';
	const REMOVE_FLAGS = '-FLAGS';
	const REMOVE_FLAGS_SILENT = '-FLAGS.SILENT';
	#</editor-fold>
}

class CCoreSocketImapMessageFlags
{
	#<editor-fold defaultstate="collapsed" desc="constants">
	const RECENT = '\Recent';
	const SEEN = '\Seen';
	const DELETED = '\Deleted';
	const FLAGGED = '\Flagged';
	const ANSWERED = '\Answered';
	const DRAFT = '\Draft';
	#</editor-fold>
}
